package Thread_;

/*
* 买火车票
* */
public class ThreadDemo1 extends Thread {
    private static int ticket = 100;
    @Override
    public void run() {
        while (true){

            if (ticket>0){
                System.out.println(getName()+"出票："+ticket);
                ticket--;
            }else {
                break;
            }
        }

    }
}
class TestThreadDemo1{
    public static void main(String[] args) {
        ThreadDemo1 threadDemo1 = new ThreadDemo1();
        threadDemo1.setName("窗口一");
        threadDemo1.start();
        ThreadDemo1 threadDemo2 = new ThreadDemo1();
        threadDemo2.setName("窗口二");
        threadDemo2.start();
        ThreadDemo1 threadDemo3 = new ThreadDemo1();
        threadDemo3.setName("窗口三");
        threadDemo3.start();
    }
}
